import 'package:boss/color_constant.dart';
import 'package:boss/ui/page/index/model/bottom_navigation.dart';
import 'package:boss/ui/page/index/widget/custom_bottom_navigation_bar_item.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class CustomBottomNavigationBar extends StatelessWidget {
  final List<BottomNavigation> items;
  final int selectedIndex;
  final ValueChanged<int> onSelectChanged;
  final TextStyle textStyle;
  final TextStyle selectedTextStyle;

  const CustomBottomNavigationBar({
    Key key,
    @required this.items,
    this.selectedIndex,
    this.onSelectChanged,
    this.textStyle,
    this.selectedTextStyle,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: MediaQuery.of(context).padding,
      decoration: BoxDecoration(
        color: Colors.white,
        boxShadow: [BoxShadow(color: ColorConstant.shadow, spreadRadius: 1.w, blurRadius: 9.w)],
      ),
      height: 98.w + MediaQuery.of(context).padding.bottom,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: items
            .map(
              (item) => item.custom == null
                  ? CustomBottomNavigationBarItem(
                      data: item,
                      isSelected: items.indexOf(item) == selectedIndex,
                      textStyle: textStyle,
                      selectedTextStyle: selectedTextStyle,
                      onTap: () {
                        if (onSelectChanged != null) {
                          onSelectChanged(items.indexOf(item));
                        }
                      },
                    )
                  : item.custom,
            )
            .toList(),
      ),
    );
  }
}
